<!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" id="form_product_detail" onsubmit="return false">
                <div class="layui-form-item">
                    <label for="productname" class="layui-form-label">
                        <span class="x-red">*</span>产品名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入产品名称
                    </div>
                </div>
                <div class="layui-form-item">
				<label for="productimg" class="layui-form-label"> <span
					class="x-red">*</span>产品图片
				</label>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn" id="test1">
						<i class="layui-icon">&#xe67c;</i>上传图片
					</button>
					<img id="imgFace" style="width: 120px" src="" /><br />
					 <input type="hidden" name="img" id="stuName" value="" class="layui-input">
				</div>
				<div class="layui-form-mid layui-word-aux">
					<span class="x-red">*</span>请上传产品图片
				</div>
			</div>
                <div class="layui-form-item">
                    <label for="productmaterial" class="layui-form-label">
                        <span class="x-red">*</span>材质
                    </label>
                    <div class="layui-input-inline">
                    	<select name="caiZhi" id="caiZhi">
                            <option value="">请选择材质</option>
                            <option value="1">其他</option>
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="marketprice" class="layui-form-label">
                        <span class="x-red">*</span>市场价
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="shiChangJia" name="shiChangJia" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入市场价
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="currentprice" class="layui-form-label">
                        <span class="x-red">*</span>现价
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="xianJia" name="xianJia" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入现价
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="deliveryaddress" class="layui-form-label">
                        <span class="x-red">*</span>发货地址
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="faHuoDiZhi" name="faHuoDiZhi" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>请输入发货地址
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="styleks" class="layui-form-label">
                        <span class="x-red">*</span>款式 
                    </label>
                    <div class="layui-input-inline">
                      <select name="kuanShi" id="kuanShi">
                        <option value="">请选择款式 </option>
                        <option value="1">其他</option>
                      </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="styleys" class="layui-form-label">
                        <span class="x-red">*</span>样式
                    </label>
                    <div class="layui-input-inline">
                      <select name="yangShi" id="yangShi">
                        <option value="">请选择样式</option>
                        <option value="1">长袖</option>
                        <option value="2">棉衣</option>
                        <option value="2">长裙</option>
                      </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="productcategory" class="layui-form-label">
                        <span class="x-red">*</span>产品类别
                    </label>
                    <div class="layui-input-inline">
                      <select name="chanPinId" id="chanPinId">
                        <option value="">请选择类别</option>
                        <option value="1">春季会场</option>
                        <option value="2">夏季会场</option>
                        <option value="3">秋季会场</option>
                        <option value="4">冬季会场</option>
                      </select>
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button onclick="addPerDetail()" class="layui-btn" lay-filter="add" >
                        	增加
                    </button>
                </div>
            </form>
        </div>
        <script src="./lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="./js/x-layui.js" charset="utf-8">
        </script>
        <script>
        	var $=null;
    		var form=null;
    		var layer=null;
    		var upload = null;
    		
            layui.use(['form','layer','upload'], function(){
                $ = layui.jquery;
              	form = layui.form;
              	layer = layui.layer;
              	upload = layui.upload;
              	
              	var uploadInst = upload.render({
    				elem : '#test1', //绑定元素
    				url : '../adminProductDetail?reqName=upload', //上传接口
    				done : function(res) {
    					//上传完毕回调
    					if (res.success) {
    						//把返回的图片名，放到img标记的src里面
    						$("#imgFace").attr("src", "../" + res.remark);
    						//把返回的图片名，保存在隐藏域里面
    						$("#stuName").val(res.remark);
    						layer.msg('新图片上传成功', {
    							icon : 6,
    							time : 1500
    						});
    					}
    				},
    				error : function() {
    					//请求异常回调
    				}
              	});
            });
            
           function addPerDetail(){
        	
           	$.post("../adminProductDetail?reqName=addProducts",$("#form_product_detail").serialize(),function(res){
           		if(res.message){
           			layer.msg(res.message,{icon:1,time:2000});
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);//关闭当前页
					parent.selProducts();
           		}else{
           			layer.msg(res.message,{icon:3,time:2000});
           		}
           	},"json");
          }
        </script>
        
    </body>

</html>